home *** CD-ROM | disk | FTP | other *** search
- // sizedde.d
- // Dumps symbol list from active drawing into Excel spreadsheet
- // Also calculates the horizontal and vertical extents in millimeters and dumps those values
- // This creates a check list in Excel with names and horizontal/vertical sizes
-
- // Copyright (c) 1991-1996 Softdesk, Inc.
- // Author: SAC 1/96
-
- HANDLE hChan; //handle to dde chanel
- HANDLE hXYChan;
- HANDLE hSymList;
- STRING sSymbol;
- STRING s, sSheet;
- XY xyMin, xyMax;
-
- SetData("UnitLinearType", 5);
- // get name of spreadsheet to use
- if (!GetUser("string", "Enter Excel Sheetname to output to", &sSheet))
- Exit(%cancel, "Macro canceled!");
-
- // default to "Sheet1"
- if (StringLength(sSheet) == 0)
- sSheet = "Sheet1";
- Print ("SheetName is ", sSheet, "\n");
-
- // start conversation with Excel
- hChan = Open("dde", "excel", sSheet);
- Print ("Conversation ", hChan, "\n");
-
- // if conversation is established (if Excel was already running)
- // poke values into the spreadsheet
- if (hChan > 0)
- {
- // title
- Poke(hChan, "r1c1", "Drafix WinCAD DDE in Action");
- // GetUser("string", "What type of symbol/Library is it?", slibtype);
- // Poke(hChan, "r
- // export symbol list
- Poke(hChan, "r5c1", "Symbol List");
- Poke(hChan, "r5c2", "X SIZE");
- Poke(hChan, "r5c3", "Y SIZE");
- Poke(hChan, "r5c4", "DONE");
- Poke(hChan, "r5c5", "CHECKED");
-
- hSymList = Open("symlist", "*");
- if (hSymList)
- {
- i = 7;
- // loop through symbols in drawing
- while (GetNextSymbol(hSymList, &sSymbol))
- {
- nCount = Symbol("getcount", sSymbol);
- GetSymbolExtent(sSymbol, &xyMin, &xyMax);
- // format r#c# reference using MakeString
- Poke(hChan, MakeString("cell", i, 1), sSymbol);
- Poke(hChan, MakeString("cell", i, 2), Format("length", abs(xyMax.x-xyMin.x)));
- Poke(hChan, MakeString("cell", i, 3), Format("length", abs(xyMax.y-xyMin.y)));
- // Poke(hChan, MakeString("cell", i, 4), Format("scalar", nCount));
- i = i+1;
- }
- }
- else
- Poke(hChan, "r11c1", "No symbols.");
-
- // an excel macro could be executed to format the data
- // using the Execute("dde", ...) command at this time.
-
- // close conversation
- Close("dde", hChan);
- }
- else
- Exit(%abort, "Couldn't start conversation with Excel\n");
-
- Exit(%ok, "Done with DDE conversation.");
- // [EndOfMacro]